from rest_framework import serializers

# SKU
from goods.models import SKU
from orders.models import OrderInfo


class SKUSerialzier(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = ('id', 'name', 'price', 'default_image_url', 'comments')

from .search_indexes import SKUIndex
from drf_haystack.serializers import HaystackSerializer

class SKUIndexSerializer(HaystackSerializer):
    """
    SKU索引结果数据序列化器
    """
    class Meta:
        index_classes = [SKUIndex]
        fields = ('text', 'id', 'name', 'price', 'default_image_url', 'comments')


# <<<<<<< HEAD
# =======
# #
# # class OrderInfoAllSerializer(serializers.ModelSerializer):
# #
# #     skus = SKUSerialzier(many=True)
# #
# #     create_time = serializers.TimeField(required=True,label='创建时间')
# #     order_id = serializers.StringRelatedField(required=True,label='订单号')
# #     pay_method = serializers
# #
# #     class Meta:
# #         model = OrderInfo
# #         # （create_time，订单号（order_id），商品信息，pay_method，订单价格（total_amount））
# #         fields = ['create_time','order_id','pay_method','total_amount','skus']
#
# >>>>>>> origin/lijianhao
